package com.example.shixi.controller;

import com.example.shixi.domain.Employee;
import com.example.shixi.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {
    @Autowired
    private IEmployeeService iEmployeeService;
    @GetMapping("/list")
    @ResponseBody
    public List<Employee> list(){
        List<Employee> employees = iEmployeeService.selectAll();
        return employees;
    }
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Long id){
        System.out.print(id);
        iEmployeeService.delete(id);
    }
    @PostMapping("/add")
    public void add(@RequestBody Employee emp){
        iEmployeeService.add(emp);
    }
    @PostMapping("/update")
    public void update(@RequestBody Employee emp){
        iEmployeeService.update(emp);
    }


}
